using System;
using System.Collections.Generic;

using Microsoft.Xna.Framework;

using Elephant.Framework;
using IDrawable = Elephant.Framework.IDrawable;

namespace Elephant.Utility.Components
{
    public abstract class Drawable : EntityComponent, IDrawable
    {
        bool visible = true;
        int drawOrder;

        #region IDrawable Members

        public virtual void Draw(GameTime gameTime) { }

        public int DrawOrder
        {
            get
            {
                return drawOrder;
            }
            set
            {
                if (drawOrder != value) {
                    drawOrder = value;
                    
                    OnDrawOrderChanged(EventArgs.Empty);
                }
            }
        }

        public event EventHandler DrawOrderChanged;

        protected virtual void OnDrawOrderChanged(EventArgs e)
        {
            if (this.DrawOrderChanged != null) {
                this.DrawOrderChanged(this, e);
            }
        }

        public virtual bool Visible
        {
            get
            {
                return visible;
            }
            set
            {
                if (visible != value) {
                    visible = value;

                    OnVisibleChanged(EventArgs.Empty);
                }
            }
        }

        public event EventHandler VisibleChanged;

        protected virtual void OnVisibleChanged(EventArgs e)
        {
            if (VisibleChanged != null) {
                VisibleChanged(this, e);
            }
        }

        #endregion
    }
}
